import {
	mapMutations
} from 'vuex'

export default {
	...mapMutations([
		'upIndexInfo',
	]),
	confirm() {
		this.handlerChangeOrderType(0, 0)
	},
	handlerChangeOrderType(e, status) {
		this.current = e
		this.page = 1
		this.list = []
		this.orderStatus = status
		this.getPageList()
	},
	submitForm(e) {
		this.page = 1
		this.list = []
		this.getPageList()
	},
	getPageList() {
		let that = this
		that.$httpRequest.request({
			that: that,
			url: 'wechat/getMySellOrderList',
			method: 'get',
			params: {
				orderStatus: that.orderStatus,
				page: that.page,
				list_rows: that.list_rows,
				keyword: that.keyword,
			},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					if (that.page === 1) {
						that.list = res.data.rows
					} else {
						that.list = that.list.concat(res.data.rows)
					}
					that.page++
				}
			}
		})
	},
	confirmShipment(id) {
		uni.navigateTo({
			url: '/pages/my/delivery?id=' + id
		})
		// let that = this
		// that.$toast.confirm({
		// 	content: `是否确认发货？`,
		// 	confirmText: '确认',
		// 	callback: result => {
		// 		if (result) {
		// 			that.$httpRequest.request({
		// 				that: that,
		// 				url: 'wechat/confirmShipping',
		// 				method: 'post',
		// 				params: {
		// 					id
		// 				},
		// 				success: res => {
		// 					if (res.code === that.$httpConfig.SUCCESS_CODE) {
		// 						this.page = 1
		// 						this.list = []
		// 						this.getPageList()
		// 					}
		// 				}
		// 			})
		// 		}
		// 	}
		// })
	},
	getStatusStr(e) {
		let str = ''
		switch (e) {
			case 1:
				str = '待付款'
				break;
			case 2:
				str = '待发货'
				break;
			case 3:
				str = '待收货'
				break;
			case 4:
				str = '待评价'
				break;
			case 5:
				str = '退款中'
				break;
			case 6:
				str = '已退款'
				break;
			case 7:
				str = '已完成'
				break;
			default:
				break;
		}
		return str
	},
	// 预览图片
	previewImage(url, index) {
		uni.previewImage({
			current: index, // 当前显示图片的链接/索引值
			urls: [url], // 需要预览的图片链接列表，photoList要求必须是数组
			loop: true // 是否可循环预览
		});
	},
	toOrderDetail(id) {
		uni.navigateTo({
			url: '/pages/my/orderDetail?id=' + id + '&saleType=' + 1
		})
	},
}